-
Notifications
You must be signed in to change notification settings - Fork 2k
unit tests for Burger (develop1) #1154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
.idea/misc.xml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. Папку .idea не нужно было загружать в репозиторий. Эта папка должна быть добавлена в .gitignore.
|
|
||
| burger.setBuns(bun); | ||
|
|
||
| assertEquals("black bun", burger.bun.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. Для юнит-тестов придерживаемся подхода: один тест, значит одна проверка. Если очень хочется несколько проверок -- тогда используем softAssertions. Поправь, пожалуйста, во всем коде
| } | ||
|
|
||
| @Test | ||
| public void setBuns_shouldAssignBun() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. Неверный нейминг. Не используем спецсимволы в названии методов
| public void removeIngredient_shouldRemoveFromList() { | ||
| Burger burger = new Burger(); | ||
| burger.setBuns(new Bun("default", 50.0f)); | ||
| Ingredient ingredient = new Ingredient(IngredientType.FILLING, "cheese", 40.0f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. Для всех зависимостей нужно использовать моки
|
|
||
| String receipt = burger.getReceipt(); | ||
|
|
||
| assertTrue(receipt.contains("(==== black bun ====)")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. Строку рецепта нужно проверять целиком, чтобы не пропустить ошибки форматирования
| String expectedPriceLine = String.format("Price: %f", burger.getPrice()); | ||
| assertTrue(receipt.contains(expectedPriceLine)); | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. Нужно написать параметризированные тесты.
| private Bun bunMock; | ||
|
|
||
| @Mock | ||
| private Ingredient ingredientMock1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. При нейминге не рекомендуется использовать числа (Field2), их еще называют magicNumbers. Очень тяжело поддерживать код с magicNumbers.
| Ingredient ingredient = new Ingredient(type, name, price); | ||
| assertEquals(price, ingredient.getPrice(), 0.0001f); | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. Нужно приложить отчет о тестировании
100% coverage for Burger — диплом часть 1